/**
 * 
 */
package com.alstudio.module.xmpp.request;

import java.util.HashMap;

import com.alstudio.module.xmpp.request.proccesser.discovery.DiscoveryRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.money.DeleteMoneyHistoryRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.money.DeleteUserPointsHistoryRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.money.GetRechargePriceRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.money.GetUserMoneyHistoryRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.money.GetUserPointsHistoryRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.money.GetUserPointsRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.props.ActivePropsRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.props.CheckPropPriceRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.props.CheckPropsListRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.props.CheckUserBuyPropsHistoryRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.props.CheckUserPropsRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.props.DeleteUserPropBuyHistoryRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.rank.CheckRankingRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.rank.RankRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.BindEmailAgainRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.BindEmailRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.ChangePassWordRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.ChargeUserRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.CheckFavoritesRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.CheckVauthStateRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.CommitUserOptionRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.CommitVoiceIntroRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.FeedBackRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.GetUserOptionsRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.useroption.StartVauthRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.AddUserFavoritesRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.AddUserSpecialFavoritesRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.AddUserToBlackListRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.CheckBlackListRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.DeleteFriendAndFanRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.DeleteUserFromBlackListRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.DeleteUserSpecialFavoritesRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.GetFriendsAndFansRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.GetUserProfileRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.GlobalSearchUsersRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.ModifyUserProfileRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.usersaction.SetUserNoteNameRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.voip.AcceptCallRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.voip.CheckVoipCallHistoryDetailRequestProcesser;
import com.alstudio.module.xmpp.request.proccesser.voip.CheckVoipCallPriceListRequestProcesser;
import com.alstudio.module.xmpp.request.proccesser.voip.CheckVoipRecordRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.voip.DeleteVoipCallHistoryDetailRequestProcesser;
import com.alstudio.module.xmpp.request.proccesser.voip.EnterBaoMiHuaRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.voip.EnterXieHouRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.voip.ExitBaoMiHuaRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.voip.HandupCallRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.voip.MakeCallRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.voip.RejcetCallRequestProccesser;
import com.alstudio.module.xmpp.request.proccesser.voip.SetVoipCallPriceRequestProcesser;
import com.alstudio.module.xmpp.request.proccesser.voip.VoipChargeRequestProcesser;
import com.alstudio.module.xmpp.request.proccesser.voip.VoipUploadLocalNetStatRequestProccesser;

/**
 * @author alonso lee
 * 
 */
public class ALUiXmppRequestManager {

	private String domain = "mk";

	private HashMap<ALUiXmppRequestType, ALUiXmppRequestInvokeCallback> requestWrappers = new HashMap<ALUiXmppRequestType, ALUiXmppRequestInvokeCallback>();

	private void registerQequestWrappers() {

		/******************************** VOIP *************************************************/
		// 处理拨打电话
		requestWrappers.put(ALUiXmppRequestType.XMPP_MAKE_CALL_REQUEST,
				new MakeCallRequestProccesser());
		// 处理接听电话
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_ACCEPT_INCOMMING_CALL_REQUEST,
				new AcceptCallRequestProccesser());
		// 处理拒绝电话
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_REJECT_INCOMMING_CALL_REQUEST,
				new RejcetCallRequestProccesser());
		// 处理挂断电话
		requestWrappers.put(ALUiXmppRequestType.XMPP_HANDUP_CALL_REQUEST,
				new HandupCallRequestProccesser());
		// 处理取消拨打电话
		requestWrappers.put(ALUiXmppRequestType.XMPP_CANCEL_CALL_REQUEST,
				new HandupCallRequestProccesser());
		// 上传本地网络情况到voip模块
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_VOIP_UPLOAD_LOCAL_NETWORK_STAT,
				new VoipUploadLocalNetStatRequestProccesser());

		// 上传本地网络情况到voip模块
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_VOIP_UPLOAD_LOCAL_NETWORK_STAT,
				new VoipUploadLocalNetStatRequestProccesser());

		// 进入爆米花
		requestWrappers.put(ALUiXmppRequestType.XMPP_ENTER_BAO_MI_HUA_REQUEST,
				new EnterBaoMiHuaRequestProccesser());
		// 退出爆米花
		requestWrappers.put(ALUiXmppRequestType.XMPP_EXIT_BAO_MI_HUA_REQUST,
				new ExitBaoMiHuaRequestProccesser());
		// 进入邂逅
		requestWrappers.put(ALUiXmppRequestType.XMPP_ENTER_XIE_HOU_REQUEST,
				new EnterXieHouRequestProccesser());

		// 请求通话记录
		requestWrappers.put(ALUiXmppRequestType.XMPP_CHECK_VOIP_RECORD_REQUEST,
				new CheckVoipRecordRequestProccesser());

		// 更新通话时间
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_VOIP_UPDATE_CALLING_TIME_REQUEST,
				new VoipChargeRequestProcesser());

		// 请求设置通话价格
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_SET_VOIP_CALL_PRICE_REQUEST,
				new SetVoipCallPriceRequestProcesser());
		// 请求获取通话价格列表
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_GET_VOIP_CALL_PRICE_REQUEST,
				new CheckVoipCallPriceListRequestProcesser());

		// 请求通话详情
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_CHECK_CALL_HISTORY_DETAIL_REQUEST,
				new CheckVoipCallHistoryDetailRequestProcesser());
		// 请求删除通话详情
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_DELETE_CALL_HISTORY_DETAIL_REQUEST,
				new DeleteVoipCallHistoryDetailRequestProcesser());
		

		/******************************** 发现 排行榜 *************************************************/

		// 发现请求
		requestWrappers.put(ALUiXmppRequestType.XMPP_DISCOVERY_REQUEST,
				new DiscoveryRequestProccesser());

		// 请求搜索
		requestWrappers.put(ALUiXmppRequestType.XMPP_GLOBAL_SEARCH_REQUEST,
				new GlobalSearchUsersRequestProccesser());

		// 请求排行榜
		requestWrappers.put(ALUiXmppRequestType.XMPP_GET_RANK_REQUEST,
				new RankRequestProccesser());

		// 请求排行榜排名
		requestWrappers.put(ALUiXmppRequestType.XMPP_GET_RANKING_RANK_RQEUST,
				new CheckRankingRequestProccesser());
		/******************************** 用戶相關操作 ****************************************/

		// 请求用户资料
		requestWrappers.put(ALUiXmppRequestType.XMPPP_GET_USER_PROFILE_REQUEST,
				new GetUserProfileRequestProccesser());

		// 请求更改用户资料
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_MODIFY_USER_PROFILE_REQUEST,
				new ModifyUserProfileRequestProccesser());

		// 请求提交语音介绍
		requestWrappers.put(ALUiXmppRequestType.XMPP_SET_VOICE_INTRO_REQUEST,
				new CommitVoiceIntroRequestProccesser());

		// 请求好友或者粉丝列表
		requestWrappers.put(ALUiXmppRequestType.XMPPP_GET_FRIEND_LISTS_REQUEST,
				new GetFriendsAndFansRequestProccesser());

		// 请求删除好友或者粉丝
		requestWrappers.put(
				ALUiXmppRequestType.XMPPP_DELETE_FRIEND_OR_FANS_REQUEST,
				new DeleteFriendAndFanRequestProccesser());

		// 关注好友
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_ADD_USER_FAVORITES_REQUEST,
				new AddUserFavoritesRequestProccesser());

		// 特别关注好友
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_ADD_SPECIAL_FAVORITES_REQUEST,
				new AddUserSpecialFavoritesRequestProccesser());

		// 取消特别关注好友
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_DELETE_SPECIAL_FAVORITES_REQUEST,
				new DeleteUserSpecialFavoritesRequestProccesser());

		// 请求设置好友备注名
		requestWrappers.put(ALUiXmppRequestType.XMPP_SET_USER_NOTENAME_REQUEST,
				new SetUserNoteNameRequestProccesser());

		// 请求加入黑名单
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_ADD_USER_TO_BLACK_LIST_REQUEST,
				new AddUserToBlackListRequestProccesser());

		// 请求解除黑名单
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_DELETE_USER_TO_BLACK_LIST_REQUEST,
				new DeleteUserFromBlackListRequestProccesser());

		// 请求我的相互关注列表
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_CHECK_FAVORITES_EACH_OTHER_REQUEST,
				new CheckFavoritesRequestProccesser());

		// 请求我的黑名单列表
		requestWrappers.put(ALUiXmppRequestType.XMPP_CHECK_BLACK_LIST_REQUEST,
				new CheckBlackListRequestProccesser());

		/******************************** 賬號設置 *************************************************/
		// 请求更改密码
		requestWrappers.put(ALUiXmppRequestType.XMPP_CHANGE_PASSWORD_REQUEST,
				new ChangePassWordRequestProccesser());
		// 请求上傳用戶配置文件
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_COMMIT_USER_OPTION_REQUEST,
				new CommitUserOptionRequestProccesser());
		// 请求獲取用戶配置文件
		requestWrappers.put(ALUiXmppRequestType.XMPP_GET_USER_OPTION_REQUEST,
				new GetUserOptionsRequestProccesser());
		// 请求發送反饋意見
		requestWrappers.put(ALUiXmppRequestType.XMPP_SEND_FEED_BACK_REQUEST,
				new FeedBackRequestProccesser());

		// 获取V认证状态
		requestWrappers.put(ALUiXmppRequestType.XMPP_CHECK_VAUTH_STATE_REQUEST,
				new CheckVauthStateRequestProccesser());

		// 请求v认证
		requestWrappers.put(ALUiXmppRequestType.XMPP_START_VAUTH_REQUEST,
				new StartVauthRequestProccesser());

		// 请求举报用户
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_ACCUSATION_CHARGE_USER_REQUEST,
				new ChargeUserRequestProccesser());

		// 绑定邮箱
		requestWrappers.put(ALUiXmppRequestType.XMPP_BIND_EMAIL_REQUEST,
				new BindEmailRequestProccesser());
		// 再次绑定邮箱
		requestWrappers.put(ALUiXmppRequestType.XMPP_BIND_EMAIL_AGEIN_REQUEST,
				new BindEmailAgainRequestProccesser());

		/*********************************** 經濟系統 *****************************************************/
		// 請求獲取充值價格列表
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_GET_RECHARGE_PRICE_REQUEST,
				new GetRechargePriceRequestProccesser());
		// 請求獲取消費記錄
		requestWrappers.put(ALUiXmppRequestType.XMPP_GET_MONEY_HISTORY_REQUEST,
				new GetUserMoneyHistoryRequestProccesser());
		// 請求刪除消費記錄
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_DELETE_MONEY_HISTORY_REQUEST,
				new DeleteMoneyHistoryRequestProccesser());
		// 請求獲取積分
		requestWrappers.put(ALUiXmppRequestType.XMPP_GET_USER_POINTS_REQUEST,
				new GetUserPointsRequestProccesser());
		// 請求獲取積分記錄
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_GET_USER_POINTS_HISTORY_REQUEST,
				new GetUserPointsHistoryRequestProccesser());
		// 請求刪除積分記錄
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_DELETE_USER_POINTS_HISTORY_REQUEST,
				new DeleteUserPointsHistoryRequestProccesser());

		/************************************** 道具系统 *****************************************************/
		// 請求刪除道具购买記錄
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_DELETE_USER_PROPS_HISTORY_REQUEST,
				new DeleteUserPropBuyHistoryRequestProccesser());

		// 請求獲取道具购买明细
		requestWrappers.put(
				ALUiXmppRequestType.XMPP_GET_USER_PROPS_HISTORY_REQUEST,
				new CheckUserBuyPropsHistoryRequestProccesser());

		// 請求用户道具
		requestWrappers.put(ALUiXmppRequestType.XMPP_GET_USER_PROPS_REQUEST,
				new CheckUserPropsRequestProccesser());

		// 請求道具价格
		requestWrappers.put(ALUiXmppRequestType.XMPP_GET_PROPS_PRICE_REQUEST,
				new CheckPropPriceRequestProccesser());

		// 請求道具商城道具列表
		requestWrappers.put(ALUiXmppRequestType.XMPP_GET_PROPS_LIST_REQUEST,
				new CheckPropsListRequestProccesser());

		// 激活道具
		requestWrappers.put(ALUiXmppRequestType.XMPP_ACTIVE_PROPS_REQUEST,
				new ActivePropsRequestProccesser());
	}

	/**
	 * 
	 */
	public ALUiXmppRequestManager() {
		// TODO Auto-generated constructor stub
		registerQequestWrappers();
	}

	public ALUiXmppRequestManager(String domain) {
		this.domain = domain;
		registerQequestWrappers();
	}

	/**
	 * 获取对应请求的xml数据
	 * 
	 * @param event
	 * @return
	 */
	public synchronized Object getRequestXml(ALUiXmppRequestEvent event) {

		ALUiXmppRequestInvokeCallback callback = requestWrappers.get(event
				.getRequestTye());
		if (callback == null)
			return null;
		return callback.getXmlData(event.getData(), domain);

	}

}
